package org.ruanjj.isPalindrome;

import org.ruanjj.linkedlist.ListNode;

public class Solution {
    public boolean isPalindrome(ListNode head){
        StringBuffer list = new StringBuffer();
        while(head != null){
            list.append(head.val);
            head = head.next;
        }
        String headString = list.toString().trim();
        int i = 0;
        int j = headString.length()-1;
        while(i < j){
            if(headString.charAt(i) == headString.charAt(j)){
                i++;
                j--;
            }else{
                return false;
            }
        }

        return true;
    }
}
